import os


def getSize(file_path):
    global size
    if os.path.exists(file_path):
        if os.path.isfile(file_path):
            size += os.path.getsize(file_path)
        else:
            files = os.listdir(file_path)
            for file in files:
                sub_file_path = os.path.join(file_path, file)
                getSize(sub_file_path)
    else:
        print("请输入一个正确的路径！")


path = input("请输入一个路径: \n")
size = 0
getSize(path)
print("文件夹的大小是:{:,}字节".format(size))
